# -*- coding:utf-8 -*-
# __author__ : "张百科"
# Date: 2021/1/25 15:21
# File: craft.py
# IDE: PyCharm
from rest_framework import serializers
from models.craft import Craft

class CraftSerializer(serializers.ModelSerializer):

    craft_category=serializers.CharField(label='工艺分类', max_length=20,  help_text='工艺分类')
    craft_category_display=serializers.SerializerMethodField(read_only=True)
    title = serializers.CharField(label='标题', help_text='标题', required=True,max_length=100)
    list_pic_url = serializers.CharField(label='列表图片', help_text='列表图片', required=False)
    standard = serializers.CharField(label='工艺标准', help_text='工艺标准', required=True)
    check_content= serializers.CharField(label='验收标准', help_text='验收标准', required=True)
    notice = serializers.CharField(label='注意事项', help_text='注意事项', required=False)
    read_count = serializers.IntegerField(read_only=True)
    update_time=serializers.DateTimeField(read_only=True)

    def get_craft_category_display(self, obj):
        return obj.get_craft_category_display()

    class Meta:
        model = Craft
        exclude = ('is_delete',)